import {defHttp} from '/@/utils/http/axios';
import {Modal} from 'ant-design-vue';

export const installAppAddon = (params) => {
  return defHttp.post({url: '/iam-service/appAddon/install', params}, { joinParamsToUrl: true });
}

export const uninstallAppAddon = (params) => {
  return defHttp.post({url: '/iam-service/appAddon/uninstall', params}, { joinParamsToUrl: true });
}

export const publishAppAddon = (params) => {
  return defHttp.post({url: '/iam-service/appAddon/publish', params}, { joinParamsToUrl: true });
}

export const getAppAddon = (params) => {
  return defHttp.get({url: '/iam-service/appAddon/get', params});
}

export const pageAppAddon = (params) => {
  return defHttp.get({url: '/iam-service/appAddon/page', params});
}

export const listAppAddon = (params) => {
  return defHttp.get({url: '/iam-service/appAddon/list', params});
}


export const saveOrUpdateAppAddon = (params, isUpdate) => {
  let url = '/iam-service/appAddon/' + (isUpdate ? 'update' : 'save');
  return defHttp.post({url: url, params});
}

export const deleteAppAddon = (params, handleSuccess) => {
  return defHttp.delete({url: '/iam-service/appAddon/delete', data: params}, {joinParamsToUrl: true}).then(() => {
    handleSuccess();
  });
}

export const batchDeleteAppAddon = (params, handleSuccess) => {
  Modal.confirm({
    title: '确认删除',
    content: '是否删除选中数据',
    okText: '确认',
    cancelText: '取消',
    onOk: () => {
      return defHttp.delete({
        url: '/iam-service/appAddon/batchDelete', data: params
     }, { joinParamsToUrl: true }).then(() => {
        handleSuccess(); 
     });
    }
  });
}
